#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
using namespace std;
class Solution
{
public:
    vector<int> countBits(int num)
    {
        vector<int> bits(num + 1, 0);
        for (int i = 1, cnt = 1; i <= num; ++i)
        {
            if (cnt << 1 == i)
                cnt <<= 1;
            bits[i] = bits[i - cnt] + 1;
        }
        return bits;
    }
};